﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace diploma.test.tools
{
    public static class TestTools
    {
        public static List<T> ReOrganizeList<T>(List<T> _list)
        {
            int n = _list.Count;
            T[] result = new T[n];
            Random rand = new Random();
            for (int i = 0; i < n; i++)
            {
                int k = rand.Next(0, n);
                while (result.Contains(_list[k]))
                {
                    k = rand.Next(0, n);
                }
                result[i] = _list[k];
            }
            List<T> res = new List<T>(result.Length);
            res.AddRange(result);
            return res;
        }

        public static bool ArraysEqual<T>(T[] a1, T[] a2)
        {
            if (ReferenceEquals(a1, a2))
                return true;

            if (a1 == null || a2 == null)
                return false;

            if (a1.Length != a2.Length)
                return false;

            EqualityComparer<T> comparer = EqualityComparer<T>.Default;
            for (int i = 0; i < a1.Length; i++)
            {
                if (!comparer.Equals(a1[i], a2[i])) return false;
            }
            return true;
        }
    }
}
